/*
 * @Date: 2024-01-02 14:09:03
 * @LastEditors: lyx
 * @LastEditTime: 2024-01-03 09:45:17
 * @FilePath: \mt-middleware-server\src\task-kafka\task-kafka.controller.ts
 * @Description:
 */
import { Controller, Inject } from '@nestjs/common';
import {
  EventPattern,
  MessagePattern,
  Payload,
  Transport,
} from '@nestjs/microservices';
import { TaskKafkaService } from './task-kafka.service';
import { ConfigService } from '@nestjs/config';
import { FeishuService } from 'src/feishu/feishu.service';
import { ObpService } from 'src/obp/obp.service';

@Controller()
export class TaskKafkaController {
  @Inject(ConfigService)
  private configService: ConfigService;

  constructor(
    private readonly taskKafkaService: TaskKafkaService,
    private readonly feishuService: FeishuService,
    private readonly obpService: ObpService,
  ) {}

  @MessagePattern('single_python_rto_alg')
  async test(@Payload() message) {
    console.log('Received message from test topic:', message);
    // 获取用户
    const { userId = '' } = message;
    const user = await this.obpService.queryOpenIdByUserId(userId);
    // 这边根据 消息 的 平台/应用 获取到指定的 openId
    console.log('user', user);
  }
}
